package com.pig4cloud.pigx.contract.executer.order.matcher;

import com.pig4cloud.pigx.contract.mongo.entity.ContractOrderMongo;

/**
 * 订单撮合器
 *
 * @since 2022/8/17 11:12
 */
public interface OrderMatcher {

	/**
	 * 获取订单信息
	 *
	 * @param id    id
	 * @param isBuy 是否是买单
	 * @return {@link ContractOrderMongo}
	 * @since 2022/8/17 21:21
	 */
	ContractOrderMongo getOrder(Long id, String isBuy);

	/**
	 * 判断是否支持
	 *
	 * @param taker 订单
	 * @return {@link boolean}
	 * @since 2022/8/17 11:20
	 */
	boolean support(ContractOrderMongo taker);

	/**
	 * 撮合订单
	 *
	 * @param taker 订单
	 * @return {@link ContractOrderMongo}
	 * @since 2022/8/17 11:15
	 */
	ContractOrderMongo match(ContractOrderMongo taker);

	/**
	 * 撮合成功
	 *
	 * @param taker 订单
	 * @since 2022/8/17 11:31
	 */
	void success(ContractOrderMongo taker);

	/**
	 * 撮合程序发生异常
	 *
	 * @param taker 订单
	 * @param e     异常
	 * @since 2022/8/17 11:31
	 */
	void fail(ContractOrderMongo taker, Exception e);
}
